﻿using System.IO;
using Common.Exceptions.UserExceptions;
using NUnit.Framework;

namespace Simhopp.Common
{
    /// <summary>
    /// Test of the class Score.
    /// </summary>
    [TestFixture]
    public class TestScore
    {
        #region FIELD REGION
        private Score defaultScore;
        private Score score;
        private User judge;
        private User wrongJudge;
        private const double TestValue = 5.0;
        #endregion
        #region TEST METHOD REGION
        [SetUp]
        public void Init()
        {
            judge = new User
            {
                UserName = "gurkan98",
                Name = "Göran Persson",
                Gender = Genders.Male,
                Age = 65,
                Nationality = "Sweden",
                AccountType = AccountTypes.Judge
            };
            wrongJudge = new User
            {
                UserName = "gurkan97",
                Name = "Göran Nilsson",
                Gender = Genders.Male,
                Age = 65,
                Nationality = "Sweden",
                AccountType = AccountTypes.NoAccess
            };
            defaultScore = new Score();
            score = new Score(judge, TestValue);
        }

        [Test]
        public void TestConstructors()
        {
            Assert.AreEqual(0.0, defaultScore.Value);
            Assert.AreEqual(null, defaultScore.Judge);
            Assert.AreEqual(TestValue, score.Value);
            Assert.AreEqual(judge, score.Judge);
        }

        [Test, ExpectedException(typeof(WrongUserException))]
        public void TestWrongUserException()
        {
            var wrongScore = new Score(wrongJudge, TestValue);
        }

        [Test]
        public void TestProperties()
        {
            defaultScore.Judge = judge;
            defaultScore.Value = TestValue;

            Assert.AreEqual(TestValue, defaultScore.Value);
            Assert.AreEqual(judge, defaultScore.Judge);
        }

        [TearDown]
        public void Terminate()
        {

        }
        #endregion
    }
}

